@extends('backend::layout')
@section('title',trans($page_title))
@section('content')
    @component('backend::component.tpl_frame')
        @slot('page_title')打印订单 @endslot
        @slot('icon') hcl-print @endslot
        @slot('tools_btn')
            @component('backend::component.form.button')
                @slot('title') 打印订单 @endslot
                @slot('color') info @endslot
                @slot('attr') id=print-btn @endslot
                @slot('icon') hcl-edit @endslot
            @endcomponent
         @endslot
        @slot('body_content')
            @if($info)
                <table class="table table-bordered tbody info-card" id="print-order">
                    <tbody>
                    <tr class="table-gray"><td colspan="6" class="text-center py-3 font-weight-bold text-secondary" style="font-size: 1.5rem;">订单详情</td></tr>
                    <tr class="table-secondary">
                        <td colspan="6" class="p-3">
                            <div>
                                <p class="py-1">订单号:{{$info->order_sn}}</p>
                                <p  class="py-1">
                                    <span class="mr-5">会员:{{$info->user->user_number}}({{$info->user->real_name}})</span>
                                    <span>下单时间:{{$info->created_at}}</span>
                                </p>
                            </div>
                            <div></div>
                        </td>
                    </tr>
                    <tr class="table-secondary"><td>货号</td><td>商品名称</td><td>价格</td><td>属性</td><td>数量</td><td>小计</td></tr>
                    @foreach($info->goods as $item)
                        <tr class="py-2"><td>{{$item->goods_number}}</td>
                            <td>{{$item->goods_name}}</td>
                            <td>{{$item->price}}</td>
                            <td>{{$item->goods_spec}}</td>
                            <td>{{$item->number}}</td> <td>{{$item->pay_money}}</td>
                        </tr>
                    @endforeach
                    <tr class="table-secondary"><td colspan="6" class="py-3">
                            <span class="float-right font-weight-bold mr-5">
                                商品总价:<code style="font-size: 18px;">{{$info->goods_price}}</code>
                                运费:<code style="font-size: 18px;">{{$info->post_cost}}</code>
                                实际支付:<code style="font-size: 18px;">{{$info->pay_price}}</code>
                            </span>
                        </td></tr>
                    <tr class="table-secondary">
                        <td colspan="3" class="p-3">
                            <p class="py-1">收件人:{{$info->consignee}}</p>
                            <p  class="py-1">联系方式:{{$info->phone}}</p>
                            <p  class="py-1">收货地址:{{$info->post_address}}</p>
                        </td>
                        <td colspan="3" class="p-3">
                            <p class="py-2">发件人:{{config('website.website_title')}}</p>
                            <p  class="py-2">联系方式:{{config('website.shop_phone')}}</p>
                            <p  class="py-2">发货地址:{{config('website.shop_address')}}</p>
                        </td>
                    </tr>
                    </tbody>
                </table>
            @else
                @component('backend::public.empty_page')
                    @slot('info') 暂时没有订单信息 @endslot
                @endcomponent
            @endif
        @endslot
    @endcomponent
@endsection
@push('scripts')
    <script src="{{asset(config('view.plugin').'/other/Print.js')}}"></script>
    <script>
        var hkey_root,hkey_path,hkey_key;
        hkey_root="HKEY_CURRENT_USER";
        hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
        //配置网页打印的页眉页脚为空
        function pagesetup_null(){
            try{
                var RegWsh = new ActiveXObject("WScript.Shell");
                hkey_key="header";
                RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
                hkey_key="footer";
                RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
                //&b 第&p页/共&P页 &b
            }catch(e){}
        }
        //配置网页打印的页眉页脚为默认值
        function pagesetup_default(){
            try{
                var RegWsh = new ActiveXObject("WScript.Shell");
                hkey_key="header";
                RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码，&p/&P")
                hkey_key="footer";
                RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d");
            }catch(e){}
        }
        $("#print-btn").click(function () {
            pagesetup_null();
            Print('#print-order')
        });
    </script>
@endpush